// +----------------------------------------------------------------------
// | CmsWing [ 网站内容管理框架 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2115 http://www.cmswing.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: arterli <arterli@qq.com>
// +----------------------------------------------------------------------
const crypto = require('crypto');
const fs = require('fs');
module.exports = class extends think.cmswing.center {
  /**
   * index action
   * @return {Promise} []
   */
  async indexAction() {
    // auto render template file index_index.html
    if (this.is_login > 0 && this.user.zhucestatus == 2) {
      if (this.isPost) {
        const userId = this.is_login;
        const data = this.post();
        data.user_id = userId;
        const insertId = await this.model('customer_service').add(data);
        if (!think.isEmpty(insertId)) {
          return this.success({name: '留言成功！'});
        } else {
          return this.fail('留言失败');
        }
      } else {
        return this.display();
      }
    } else {
      return this.fail('留言失败');
    }
  }
};
